<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="${projectConfig.basePackage}.${config.model}.mapper.gen.${config.objectName}Mapper">
<#if columns?size != 0>
  <resultMap id="BaseResultMap" type="${projectConfig.beanPackage}.${config.model}.bean.bo.gen.${config.objectName}">
  <#list columns as prop>
   <#if prop.jdbcType?exists>
    <result column="<#if projectConfig.columnType=="upper">${prop.name?upper_case}<#elseif projectConfig.columnType=="lower">${prop.name?lower_case}<#else>${prop.name}</#if>"
            property="${prop.alias}" jdbcType="${prop.jdbcType}"/>
   </#if>
  </#list>
  </resultMap>
</#if>
  
<#list method as methodp>
    <#if methodp.outType == "String">
  <select id="${methodp.name}" parameterType="java.util.Map" resultType="java.lang.String"
          <#if methodp.statementType??>statementType="${methodp.statementType}"</#if>>
      ${methodp.sql}
  </select>
    <#elseif methodp.outType == "ListInteger">
  <select id="${methodp.name}" parameterType="java.util.Map" resultType="java.lang.Integer"
          <#if methodp.statementType??>statementType="${methodp.statementType}"</#if>>
    <#if projectConfig.dbType == "oralce">
    <if test="limitStart != null">
        SELECT * FROM(
        SELECT A.*, ROWNUM RN
        FROM (
    </if>
    <#elseif projectConfig.dbType == "mysql">
    <#elseif projectConfig.dbType == "postgresql">
    </#if>
      ${methodp.sql}
      <if test="orderBy != null">
          order by ${"$"}{orderBy}
      </if>
   <#if projectConfig.dbType == "oralce">
    <if test="limitStart != null">
        ) A WHERE ROWNUM &lt;= ${"#"}{limitStart} + ${"#"}{limitOffset} ) WHERE RN &gt; ${"#"}{limitStart}
    </if>
   <#elseif projectConfig.dbType == "mysql">
    <if test="limitStart != null">
        limit ${"#"}{limitStart} , ${"#"}{limitOffset}
    </if>
   <#elseif projectConfig.dbType == "postgresql">
    <if test="limitStart != null">
        limit ${"#"}{limitOffset} offset ${"#"}{limitStart}
    </if>
   </#if>

  </select>
  <select id="${methodp.name}Count" parameterType="java.util.Map" resultType="java.lang.Integer">
      select count(*) from ( ${methodp.sql}) count_t
  </select>
    <#elseif methodp.outType == "ListLong">
  <select id="${methodp.name}" parameterType="java.util.Map" resultType="java.lang.Long"
          <#if methodp.statementType??>statementType="${methodp.statementType}"</#if>>
    <#if projectConfig.dbType == "oralce">
    <if test="limitStart != null">
        SELECT * FROM(
        SELECT A.*, ROWNUM RN
        FROM (
    </if>
    <#elseif projectConfig.dbType == "mysql">
    <#elseif projectConfig.dbType == "postgresql">
    </#if>
      ${methodp.sql}
      <if test="orderBy != null">
          order by ${"$"}{orderBy}
      </if>
   <#if projectConfig.dbType == "oralce">
    <if test="limitStart != null">
        ) A WHERE ROWNUM &lt;= ${"#"}{limitStart} + ${"#"}{limitOffset} ) WHERE RN &gt; ${"#"}{limitStart}
    </if>
   <#elseif projectConfig.dbType == "mysql">
    <if test="limitStart != null">
        limit ${"#"}{limitStart} , ${"#"}{limitOffset}
    </if>
   <#elseif projectConfig.dbType == "postgresql">
    <if test="limitStart != null">
        limit ${"#"}{limitOffset} offset ${"#"}{limitStart}
    </if>
   </#if>

  </select>
  <select id="${methodp.name}Count" parameterType="java.util.Map" resultType="java.lang.Integer">
      select count(*) from ( ${methodp.sql}) count_t
  </select>
    <#elseif methodp.outType == "ListString">
  <select id="${methodp.name}" parameterType="java.util.Map" resultType="java.lang.String"
          <#if methodp.statementType??>statementType="${methodp.statementType}"</#if>>
    <#if projectConfig.dbType == "oralce">
    <if test="limitStart != null">
        SELECT * FROM(
        SELECT A.*, ROWNUM RN
        FROM (
    </if>
    <#elseif projectConfig.dbType == "mysql">
    <#elseif projectConfig.dbType == "postgresql">
    </#if>
      ${methodp.sql}
      <if test="orderBy != null">
          order by ${"$"}{orderBy}
      </if>
    <#if projectConfig.dbType == "oralce">
    <if test="limitStart != null">
        ) A WHERE ROWNUM &lt;= ${"#"}{limitStart} + ${"#"}{limitOffset} ) WHERE RN &gt; ${"#"}{limitStart}
    </if>
    <#elseif projectConfig.dbType == "mysql">
    <if test="limitStart != null">
        limit ${"#"}{limitStart} , ${"#"}{limitOffset}
    </if>
    <#elseif projectConfig.dbType == "postgresql">
    <if test="limitStart != null">
        limit ${"#"}{limitOffset} offset ${"#"}{limitStart}
    </if>
    </#if>
  </select>
  <select id="${methodp.name}Count" parameterType="java.util.Map" resultType="java.lang.Integer">
      select count(*) from ( ${methodp.sql}) count_t
  </select>
    <#elseif methodp.outType == "Integer">
        <#if methodp.methodType == "update">
  <update id="${methodp.name}" <#if methodp.inType??><#if methodp.inType=="Object">parameterType="${projectConfig.beanPackage}.${config.model}.bean.bo.gen.${config.objectName}"
          <#else>parameterType="java.util.Map"</#if><#else>parameterType="java.util.Map"</#if>
          <#if methodp.statementType??>statementType="${methodp.statementType}"</#if>>
      ${methodp.sql}
  </update>
        <#elseif methodp.methodType == "insert">
  <insert id="${methodp.name}" <#if methodp.inType??><#if methodp.inType=="Object">parameterType="${projectConfig.beanPackage}.${config.model}.bean.bo.gen.${config.objectName}"
          <#else>parameterType="java.util.Map"</#if><#else>parameterType="java.util.Map"</#if>
          <#if methodp.statementType??>statementType="${methodp.statementType}"</#if>>
      ${methodp.sql}
  </insert>
        <#elseif methodp.methodType == "delete">
  <delete id="${methodp.name}" parameterType="java.util.Map"
          <#if methodp.statementType??>statementType="${methodp.statementType}"</#if>>
      ${methodp.sql}
  </delete>
        <#else>
  <select id="${methodp.name}" parameterType="java.util.Map" resultType="java.lang.Integer"
          <#if methodp.statementType??>statementType="${methodp.statementType}"</#if>>
      ${methodp.sql}
  </select>
        </#if>
    <#elseif methodp.outType == "Object">
  <select id="${methodp.name}" parameterType="java.util.Map" resultMap="BaseResultMap"
          <#if methodp.statementType??>statementType="${methodp.statementType}"</#if>>
      ${methodp.sql}
  </select>
    <#elseif methodp.outType == "Map">
  <select id="${methodp.name}" parameterType="java.util.Map" resultType="java.util.Map"
          <#if methodp.statementType??>statementType="${methodp.statementType}"</#if>>
      ${methodp.sql}
  </select>
    <#elseif methodp.outType == "ListObject">
  <select id="${methodp.name}" parameterType="java.util.Map" resultMap="BaseResultMap"
          <#if methodp.statementType??>statementType="${methodp.statementType}"</#if>>
    <#if projectConfig.dbType == "oralce">
    <if test="limitStart != null">
        SELECT * FROM(
        SELECT A.*, ROWNUM RN
        FROM (
    </if>
    <#elseif projectConfig.dbType == "mysql">
    <#elseif projectConfig.dbType == "postgresql">
    </#if>
      ${methodp.sql}
      <if test="orderBy != null">
          order by ${"$"}{orderBy}
      </if>
    <#if projectConfig.dbType == "oralce">
    <if test="limitStart != null">
        ) A WHERE ROWNUM &lt;= ${"#"}{limitStart} + ${"#"}{limitOffset} ) WHERE RN &gt; ${"#"}{limitStart}
    </if>
    <#elseif projectConfig.dbType == "mysql">
    <if test="limitStart != null">
        limit ${"#"}{limitStart} , ${"#"}{limitOffset}
    </if>
    <#elseif projectConfig.dbType == "postgresql">
    <if test="limitStart != null">
        limit ${"#"}{limitOffset} offset ${"#"}{limitStart}
    </if>
    </#if>
  </select>
  <select id="${methodp.name}Count" parameterType="java.util.Map" resultType="java.lang.Integer">
      select count(*) from ( ${methodp.sql}) count_t
  </select>
    <#elseif methodp.outType == "ListMap">
     <select id="${methodp.name}" parameterType="java.util.Map" resultType="java.util.Map"
             <#if methodp.statementType??>statementType="${methodp.statementType}"</#if>>
         <#if projectConfig.dbType == "oralce">
             <if test="limitStart != null">
                 SELECT * FROM(
                 SELECT A.*, ROWNUM RN
                 FROM (
             </if>
         <#elseif projectConfig.dbType == "mysql">
         <#elseif projectConfig.dbType == "postgresql">
         </#if>
         ${methodp.sql}
         <if test="orderBy != null">
             order by ${"$"}{orderBy}
         </if>
         <#if projectConfig.dbType == "oralce">
             <if test="limitStart != null">
                 ) A WHERE ROWNUM &lt;= ${"#"}{limitStart} + ${"#"}{limitOffset} ) WHERE RN &gt; ${"#"}{limitStart}
             </if>
         <#elseif projectConfig.dbType == "mysql">
             <if test="limitStart != null">
                 limit ${"#"}{limitStart} , ${"#"}{limitOffset}
             </if>
         <#elseif projectConfig.dbType == "postgresql">
             <if test="limitStart != null">
                 limit ${"#"}{limitOffset} offset ${"#"}{limitStart}
             </if>
         </#if>
     </select>
     <select id="${methodp.name}Count" parameterType="java.util.Map" resultType="java.lang.Integer">
         select count(*) from ( ${methodp.sql}) count_t
     </select>
    </#if>
</#list>

</mapper>